#!/bin/sh

# 文本输出
printInfo(){
	echo "\033[32m✔︎\033[0m $1 \033[36m>>>\033[0m $2"
}

# 重新初始化
reinit=false

while getopts :r opt; do
    case $opt in
        # 页端分支
        r) reinit=true ;;
    esac
done

if [ "$reinit" = true ];then
	printInfo "REINIT" "reinit project"

	if [ -d server ];then
		printInfo "CLEAN" "server"
		rm -rf server
	fi

	if [ -f .inited ];then
		printInfo "CLEAN" ".inited"
		rm .inited
	fi
	echo ""
fi


if [ -f .inited ];then
	printInfo "DONE" "project has been inited."
	exit 0
fi

if [ ! -d server ];then
    printInfo "CREATE" "server"
    mkdir server
fi

echo ""

printInfo "CLONE" "pi-server.git"
git clone git@git.wxpai.cn:pi-plusplus/pi-server.git ./server

# 已初始化标志
touch .inited

printInfo "DONE" ""
